<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 1.定义一个set
      let set1 = new Set(["h1", "h2", "h1"]);
      console.log(set1);
      //   2.add 添加元素
      set1.add("ccc");
      console.log(set1);
      //   3.获取集合的大小
      console.log(set1.size);
      set1.delete("h2");
      console.log(set1);
      //   4.clear 删除所有元素
      //   set1.clear();
      // 5. 转换成数组
      let arr = Array.from(set1);
      console.log(arr);
      //   6.数组转换成set
      arr = [...arr, "h2", "h1"];
      console.log(arr);
      console.log(new Set(arr));
      //   7.kesy() / values entries
      console.log(set1.keys());
      //   8. has(ele) 判断元素是否在集合当中
    </script>
  </body>
</html>
